package main

import (
	"cms/core"
	"cms/core/cache"
	"cms/core/config"
	"cms/routes"
	"github.com/gin-gonic/gin"
)

func main() {
	config.LoadConfig()
	app := gin.Default()
	app.Use(core.LoggerToFile())
	routes.RegisterAdmin(app)

	app.NoRoute(func(ctx *gin.Context) {
		ctx.JSON(404, gin.H{
			"success": false,
			"message": "path not exist",
		})
	})
	app.Static("./uploads", "./uploads")

	core.InitDb()
	core.InitCasbin()

	cache.InitRedis()

	err := app.Run(":9001")
	if err != nil {
		panic(err)
	}
}
